from pitchSrc.tools.getPlotly import get2dFig, get2dFig
from pitchSrc.tools.loadFile import toLineRegressCsv, toAttrCsv, toLineRegressAttrCsv, fitLineRegressCsv

from common.config import pitchConfig as Config

def lineRegressProcess():
    toLineRegressCsv(Config.hisSurfaceProcess, Config.hisLineRegress)
    #fitLineRegressCsv(Config.hisLineRegress, Config.hisLineRegress)  # 曲线拟合
    toLineRegressAttrCsv(Config.hisLineRegress, Config.hisLineRegressAttr)

    # get2dFig_2(Config.hisLineRegress).show()

    #fig = get2dFig(Config.hisSurfaceProcess)
    #fig.show()

    # f1 = np.polyfit(points_maxPower[Config.WindSpeed], points_maxPower[Config.PitchAngle], 4)  # 返回多项式系数
    # func = np.poly1d(f1)  # 返回多项式表达式（多项式函数）
    # direction_fit = func(points_maxPower[Config.WindSpeed])
    # df2 = pd.DataFrame({'PitchAngle':direction_fit, 'WindSpeed':points_maxPower[Config.WindSpeed]})
    #
    # fig2 = px.line(df2, x='PitchAngle', y='WindSpeed', title='偏航误差曲线', range_x=[-6, 6])
    # fig2.show()

if __name__ == '__main__':
    lineRegressProcess()




